// src/api/userApi.js
import axios from 'axios'

// 认证 API 基础路径
const AUTH_URL = '/api/user'

/**
 * 用户登录
 * @param {string} username
 * @param {string} password
 */
export const login = (username, password) => {
  return axios.post(`${AUTH_URL}/login`, { username, password })
}

/**
 * 用户注册
 * @param {string} username
 * @param {string} password
 * @param {string} email
 */
export const register = (username, password, email) => {
  return axios.post(`${AUTH_URL}/register`, { username, password, email })
}

/**
 * 对应后端接口: GET /api/user/current
 * 获取当前登录用户的 ID
 */
export const getCurrentUserId = () => {
  return axios.get('/api/user/current')
}

/**
 * 对应后端接口: GET /api/creations/user/{userId}
 * 获取用户创作历史 (假设您之前有这个接口)
 */
export const getUserCreations = (userId) => {
  return axios.get(`/api/creations/user/${userId}`)
}

/**
 * 对应后端接口: GET /api/ratings/user/{userId} (新增 - 假设后端会提供)
 * 获取用户评分历史
 */
export const getUserRatings = (userId) => {
  // 🚨 假设后端会提供一个 /api/ratings/user/{userId} 接口来查询用户的所有评分记录
  return axios.get(`/api/ratings/user/${userId}`)
}
